package com.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mapper.ItemMapper;
import com.pojo.Item;
import com.service.ItemService;
import com.vo.ChargeItemVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service("itemService")
public class ItemServiceImpl implements ItemService {
    @Resource
    private ItemMapper itemMapper;
    @Override
    public PageInfo<Item> selectItemByCondition(ChargeItemVo chargeItemVo) {
        PageHelper.startPage(chargeItemVo.getPage(),chargeItemVo.getLimit());
        List<Item> itemList = itemMapper.selectItemByCondition(chargeItemVo);
        PageInfo<Item> pageInfo=new PageInfo<>(itemList);
        return pageInfo;
    }

    @Override
    public int updateItem(Item item) {
        int i = itemMapper.updateByPrimaryKey(item);
        return i;
    }

    @Override
    public int deleteById(Integer id) {
        int i = itemMapper.deleteByPrimaryKey(id);
        return i;
    }

    @Override
    public int addItem(Item item) {
        int insert = itemMapper.insert(item);
        return insert;
    }

    @Override
    public Item selectItemById(Integer id) {
        Item item = itemMapper.selectItemById(id);
        return item;
    }
    @Override
    public List<Item> selectItemOther() {
        List<Item> itemList = itemMapper.selectItemin();
        return itemList;
    }
    @Override
    public List<Item> selectAllGuDingItem() {
        List<Item> items = itemMapper.selectAllGuDingItem();
        return items;
    }

}
